package com.forezp.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.forezp.service.DeviceTypeService;
import com.github.pagehelper.PageInfo;
import com.service.base.ResponseResult;
import com.service.bean.DeviceType;

@RestController

public class DeviceTypeController {
	@Autowired
	private DeviceTypeService deviceTypeService;
	
	@RequestMapping("/getTypeList")
	public ResponseResult getTypeList(@RequestBody DeviceType deviceType,
			@RequestParam("pageNumber") Integer pageNumber,
			@RequestParam("pageSize") Integer pageSize){
//		System.out.println("000000----------0000000----" +pageNumber 
//				+"-------" +pageSize +"-----code-----" + deviceType.getCode());
//		DeviceType deviceType = new DeviceType();
		deviceType.setIsdelete("0");
		PageInfo<DeviceType> deviceTypePage = deviceTypeService.getPage(deviceType,
				pageNumber, pageSize);
		
		
		System.out.println("0000====----"+deviceTypePage.getList().size());
        return ResponseResult.ok(deviceTypePage);
		
	}
	
	@RequestMapping("/insertType")
	public int insertType(@RequestBody DeviceType deviceType){
		deviceType.setCreateDate(new Date());
		deviceType.setUpdateDate(new Date());
		deviceType.setCreatedBy(1L);
		deviceType.setUpdatedby(1L);
		return deviceTypeService.insertDeviceType(deviceType);
	}

	@RequestMapping("/delType")
	public int delType(@RequestBody DeviceType deviceType){
		deviceType.setUpdateDate(new Date());
		deviceType.setUpdatedby(1L);
		return deviceTypeService.updateById(deviceType);
	}
	
	@RequestMapping("/getType")
	public DeviceType getType(@RequestParam Integer deviceTypeId){
		return deviceTypeService.getById(deviceTypeId);
	}
	
	@RequestMapping("/updateType")
	public int getType(@RequestBody DeviceType deviceType){
		return deviceTypeService.updateById(deviceType);
	}
	
	@RequestMapping("/getDeviceTypeList")
	public List<DeviceType> getDeviceTypeList(){
		DeviceType deviceType=new DeviceType();
		return deviceTypeService.getList(deviceType);
	}
	
	
}
